#region

using System.Runtime.InteropServices;

#endregion

namespace MediaController.Extractor
{
    public sealed class DriveInfo
    {
        public readonly long Available;
        public readonly string Drive;
        public readonly long Result;
        public readonly long Total;
        private readonly long _free;
        private long Allocated;


        public DriveInfo(string drive)
        {
            long num2;
            long num3;
            long num4;
            long num = GetDiskFreeSpaceEx(drive, out num2, out num3, out num4);
            Drive = drive;
            Result = num;
            Available = num2;
            Total = num3;
            _free = num4;
        }

        public long Free
        {
            get { return (_free - Allocated); }
        }

        internal void Allocate(int p2)
        {
            Allocated += p2;
        }

        internal bool CanAllocte(int p2)
        {
            return ((Free - p2) > 0L);
        }

        [DllImport("kernel32.dll", EntryPoint = "GetDiskFreeSpaceExA")]
        private static extern long GetDiskFreeSpaceEx(string lpDirectoryName, out long lpFreeBytesAvailableToCaller,
                                                      out long lpTotalNumberOfBytes, out long lpTotalNumberOfFreeBytes);

        // Properties
    }
}